//package com.example.lcqexcel.test;
//
//import com.alibaba.excel.annotation.write.style.ColumnWidth;
//import com.alibaba.excel.annotation.write.style.ContentRowHeight;
//import com.alibaba.excel.converters.Converter;
//import com.alibaba.excel.enums.CellDataTypeEnum;
//import com.alibaba.excel.metadata.GlobalConfiguration;
//import com.alibaba.excel.metadata.data.ImageData;
//import com.alibaba.excel.metadata.data.WriteCellData;
//import com.alibaba.excel.metadata.property.ExcelContentProperty;
//import com.alibaba.excel.metadata.property.StyleProperty;
//import com.alibaba.excel.util.FileUtils;
//import com.alibaba.excel.util.ListUtils;
//import org.apache.commons.collections4.CollectionUtils;
//
//import java.io.File;
//import java.io.IOException;
//import java.lang.reflect.Field;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @ClassName FileListImageConverter
// * @Description
// * @Author lichuanqi
// * @Date 2022/3/25 15:29
// * @Version 1.0
// **/
//public class FileListImageConverter implements Converter<List<File>> {
//    @Override
//    public Class<?> supportJavaTypeKey() {
//        return List.class;
//    }
//
//    @Override
//    public WriteCellData<?> convertToExcelData(List<File> imageList,
//                                               ExcelContentProperty contentProperty,
//                                               GlobalConfiguration globalConfiguration) throws IOException {
//        if (CollectionUtils.isEmpty(imageList)){
//            return new WriteCellData<>();
//        }
//        int factor = 6;  //注解宽度与ImageData比例关系
//        int columnWidth = 100*factor;
//
//        Field field = contentProperty.getField();
//        ColumnWidth[] widthAnnotation = field.getAnnotationsByType(ColumnWidth.class);
//        if (widthAnnotation != null &&widthAnnotation.length>0){
//            for (ColumnWidth columnWidthA : widthAnnotation) {
//                columnWidth = columnWidthA.value()*factor;
//            }
//        }
//
//        List<ImageData> imageDataList = new ArrayList<>();
//        int left = 0;
//        int imageWidth = columnWidth/imageList.size();
//        for (File file : imageList) {
//            byte[] image = FileUtils.readFileToByteArray(file);
//            ImageData imageData = new ImageData();
//            imageData.setLeft(left);
//            imageData.setRight(columnWidth-imageWidth-left);
//            imageData.setImage(image);
//            imageDataList.add(imageData);
//            left+=imageWidth;
//        }
//
//        WriteCellData<Void> writeCellData = new WriteCellData<>();
//        writeCellData.setType(CellDataTypeEnum.EMPTY);
//        writeCellData.setImageDataList(imageDataList);
//
//        return writeCellData;
//    }
//}
